from src.recommender import MLRecommender
import pandas as pd
import random


def main():
    # 初始化推荐器
    print("Loading recommendation models...")
    recommender = MLRecommender()

    # 获取用户列表
    users = pd.read_csv("data/raw/users.csv")

    # 测试推荐
    while True:
        # 随机选择一个用户
        user_id = random.choice(users['user_id'].values)
        print(f"\nGenerating recommendations for user: {user_id}")

        # 获取推荐
        recommendations = recommender.get_recommendations(user_id, n=5)

        # 打印结果
        print("\nTop Recommendations:")
        for i, row in recommendations.iterrows():
            print(f"{i + 1}. [{row['category']}] {row['name']} - ¥{row['price']} | Score: {row['score']:.4f}")

        # 等待用户输入
        input("\nPress Enter to generate another recommendation...")


if __name__ == "__main__":
    main()